home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / dirent / dirent.h < prev    next >
C/C++ Source or Header  |  1994-01-06  |  4KB  |  129 lines

  1. /* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. /*
  20.  *    POSIX Standard: 5.1.2 Directory Operations    <dirent.h>
  21.  */
  22.  
  23. #ifndef    _DIRENT_H
  24.  
  25. #define    _DIRENT_H    1
  26. #include <features.h>
  27.  
  28. __BEGIN_DECLS
  29.  
  30. #include <gnu/types.h>
  31.  
  32.  
  33. /* Directory entry structure.
  34.  
  35.    This structure is laid out identically to the `struct direct' that
  36.    represents directory entries in the GNU Hurd and in BSD Unix (and
  37.    incidentally, on disk in the Berkeley fast file system).  The `readdir'
  38.    implementations for GNU and BSD know this; you must change them if you
  39.    change this structure.  */
  40.  
  41. struct dirent
  42.   {
  43.     __ino_t d_fileno;        /* File serial number.  */
  44.     unsigned short int d_reclen; /* Length of the whole `struct dirent'.  */
  45.     unsigned short int d_namlen; /* Length of the file name.  */
  46.  
  47.     /* Only this member is in the POSIX standard.  */
  48.     char d_name[1];        /* File name (actually longer).  */
  49.   };
  50.  
  51. #if defined(__USE_BSD) || defined(__USE_MISC)
  52. #define    d_ino        d_fileno /* Backward compatibility.  */
  53. #endif
  54.  
  55. /* Get the system-dependent definition of `DIR',
  56.    the data type of directory stream objects.  */
  57. #include <dirstream.h>
  58.  
  59. /* Open a directory stream on NAME.
  60.    Return a DIR stream on the directory, or NULL if it could not be opened.  */
  61. extern DIR *opendir __P ((__const char *__name));
  62.  
  63. /* Close the directory stream DIRP.
  64.    Return 0 if successful, -1 if not.  */
  65. extern int closedir __P ((DIR * __dirp));
  66.  
  67. /* Read a directory entry from DIRP.
  68.    Return a pointer to a `struct dirent' describing the entry,
  69.    or NULL for EOF or error.  The storage returned may be overwritten
  70.    by a later readdir call on the same DIR stream.  */
  71. extern struct dirent *readdir __P ((DIR * __dirp));
  72.  
  73. /* Rewind DIRP to the beginning of the directory.  */
  74. extern void rewinddir __P ((DIR * __dirp));
  75.  
  76. #if defined(__USE_BSD) || defined(__USE_MISC)
  77.  
  78. #ifndef    MAXNAMLEN
  79. /* Get the definitions of the POSIX.1 limits.  */
  80. #include <posix1_lim.h>
  81.  
  82. /* `MAXNAMLEN' is the BSD name for what POSIX calls `NAME_MAX'.  */
  83. #ifdef    NAME_MAX
  84. #define    MAXNAMLEN    NAME_MAX
  85. #else
  86. #define    MAXNAMLEN    255
  87. #endif
  88. #endif
  89.  
  90. #include <gnu/types.h>
  91. #define __need_size_t
  92. #include <stddef.h>
  93.  
  94. /* Seek to position POS on DIRP.  */
  95. extern void seekdir __P ((DIR * __dirp, __off_t __pos));
  96.  
  97. /* Return the current position of DIRP.  */
  98. extern __off_t telldir __P ((DIR * __dirp));
  99.  
  100. /* Scan the directory DIR, calling SELECT on each directory entry.
  101.    Entries for which SELECT returns nonzero are individually malloc'd,
  102.    sorted using qsort with CMP, and collected in a malloc'd array in
  103.    *NAMELIST.  Returns the number of entries selected, or -1 on error.  */
  104. extern int scandir __P ((__const char *__dir,
  105.              struct dirent ***__namelist,
  106.              int (*__select) __P ((struct dirent *)),
  107.              int (*__cmp) __P ((__const __ptr_t,
  108.                         __const __ptr_t))));
  109.  
  110. /* Function to compare two `struct dirent's alphabetically.  */
  111. extern int alphasort __P ((__const __ptr_t, __const __ptr_t));
  112.  
  113.  
  114. /* Read directory entries from FD into BUF, reading at most NBYTES.
  115.    Reading starts at offset *BASEP, and *BASEP is updated with the new
  116.    position after reading.  Returns the number of bytes read; zero when at
  117.    end of directory; or -1 for errors.  */
  118. extern __ssize_t __getdirentries __P ((int __fd, char *__buf,
  119.                        size_t __nbytes, __off_t *__basep));
  120. extern __ssize_t getdirentries __P ((int __fd, char *__buf,
  121.                      size_t __nbytes, __off_t *__basep));
  122.  
  123.  
  124. #endif /* Use BSD or misc.  */
  125.  
  126. __END_DECLS
  127.  
  128. #endif /* dirent.h  */
  129.